package com.wsleo.jblog.model.article;

import java.util.List;
import java.util.Map;

import com.wsleo.jblog.model.BaseModel;
import com.wsleo.jblog.model.common.Source;
import com.wsleo.jblog.model.common.Status;

/**
 * Article.java
 */
public class Article extends BaseModel {

    private static final long serialVersionUID = 1L;
    
    private String aliasName;
    private ArticleCatalog catalog;
    private Long catalogId = -1L;
    private String title;
    private Boolean isTop = false;
    private String author;
    private String descript;
    private String content;
    private List<ArticleTag> tags;
    private Long scan = 0L;
    private Source source = Source.RESHIPMENT;
    private Status status = Status.NORMAL;
    private Boolean isAllowComment = true;
    private List<ArticleComment> comments;

    public String getAliasName() {
        return aliasName;
    }

    public void setAliasName(String aliasName) {
        this.aliasName = aliasName;
    }

    public ArticleCatalog getCatalog() {
        return catalog;
    }

    public void setCatalog(ArticleCatalog catalog) {
        this.catalog = catalog;
        this.catalogId = catalog.getId();
    }

	public Long getCatalogId() {
		return catalogId;
	}

	public void setCatalogId(Long catalogId) {
		this.catalogId = catalogId;
	}

	public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Boolean getIsTop() {
        return isTop;
    }

    public void setIsTop(Boolean isTop) {
        this.isTop = isTop;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getDescript() {
        return descript;
    }

    public void setDescript(String descript) {
        this.descript = descript;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public List<ArticleTag> getTags() {
        return tags;
    }

    public void setTags(List<ArticleTag> tags) {
        this.tags = tags;
    }

    public Long getScan() {
        return scan;
    }

    public void setScan(Long scan) {
        this.scan = scan;
    }

    public Source getSource() {
        return source;
    }

    public void setSource(Source source) {
        this.source = source;
    }

    public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Boolean getIsAllowComment() {
        return isAllowComment;
    }

    public void setIsAllowComment(Boolean isAllowComment) {
        this.isAllowComment = isAllowComment;
    }

    public List<ArticleComment> getComments() {
        return comments;
    }

    public void setComments(List<ArticleComment> comments) {
        this.comments = comments;
    }
    
    @Override
    protected Map<String, Object> ListInsertableFields() {
        Map<String, Object> map = super.ListInsertableFields();
//        map.remove("tags");
//        map.remove("comments");
//        map.put("catalogId", catalog.getId());
        return map;
    }

    @Override
    public String toString() {
        return "Article [aliasName=" + aliasName + ", catalog=" + catalog + ", catalogId=" + catalogId
                + ", title=" + title + ", isTop=" + isTop + ", author=" + author + ", descript="
                + descript + ", content=" + content + ", scan=" + scan
                + ", source=" + source + ", status=" + status
                + ", createTime=" + getCreateTime() + ", lastUpdTime=" 
                + getLastUpdTime() + ", lastUpdBy=" + getLastUpdBy() 
                + ", isAllowComment=" + isAllowComment + ", id=" + getId() + "]";
    }
    
}